#ifndef ANIMBASE_H
#define ANIMBASE_H

#include <QString>
#include <QList>
#include <QVariant>
#include <QPointF>
#include <QSizeF>
#include <animconst.h>
#include <interpolator.h>

struct SubAnim
{
    AnimType Type = Reserved;
    QVariant Dest;
    double Period = 0.0;
    AccelType Accel = Linear;
};

struct AnimOp
{
    double At;
    OpCode Code;
    QString ObjName;
    SubAnim Anim; // SubAnim in case of an animation transition
    QStringList Args; // Args in case of an control operation (spawn)
};

struct ParsedLine
{
    double At;
    TokenType Token;
    QList<QString> Fields;
};

struct AnimEntity
{
    ~AnimEntity();

    // How to draw
    QImage *Img;
    QPointF Pos;
    QSizeF Size;
    double Rotation, Opacity;

    // How to animate
    Interpolator<QPointF> *PosInterpolator = nullptr;
    Interpolator<QSizeF> *SizeInterpolator = nullptr;
    Interpolator<double> *RotationInterpolator = nullptr;
    Interpolator<double> *OpacityInterpolator = nullptr;
};

ParsedLine ParseAnimLine(QString, bool ignoreAtValidity);
AnimOp CreateOpFromLine(ParsedLine);


#endif // ANIMBASE_H
